// 定义记分牌
export default class Panel{
    score = 0;
    level = 1;
    scoreEle :HTMLElement;
    levelEle: HTMLElement;
    constructor(
        public maxLevel:number =10,
        public upScore:number = 10
    ){
        this.scoreEle = document.getElementById('score')
        this.levelEle = document.getElementById('level')
    }
    //重置记分牌
    reset(){
        this.score = 0;
        this.level = 1;
        this.scoreEle.innerHTML = this.score+'';
        this.levelEle.innerHTML = this.level+''
    }
    //设置加分的方法
    addScore(){
        this.score++;
        this.scoreEle.innerHTML = this.score+''
        //判断分数多少
        if(this.score%this.upScore ===0){
            this.addLevel()
        }
    }
    //设置加等级的方法
    addLevel(){
        if(this.level<this.maxLevel){
            this.level++;
        }
        this.levelEle.innerHTML = this.level+''
    }
}

const panel = new Panel()
panel.reset()
